package com.mindao.app.site.controller;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mindao.app.common.spring.controller.BaseController;
import com.mindao.app.common.spring.model.BaseModel;
import com.mindao.app.common.spring.page.Pagination;
import com.mindao.app.common.spring.service.util.JsonResult;
import com.mindao.app.ea.service.UserService;
import com.mindao.app.site.model.Event;
import com.mindao.app.site.model.EventEnroll;
import com.mindao.app.site.service.EventService;
import com.mindao.app.site.util.SiteConstants;
import com.mindao.utils.config.EaCommonUtils;
import com.mindao.utils.config.EaConstant;

/**
/* 版权所有： 广州敏道科技有限公司
/*
/* 功能描述：
/*
/* 创 建 人：李国才
/* 创建时间：2016年6月16日 下午1:03:24 	
 **/
@Controller
@RequestMapping("/site/eventenroll")
public class EventEnrollController extends BaseController<EventEnroll> {
	private final Logger log = LoggerFactory.getLogger(EventEnrollController.class);
	
	@Autowired
	protected UserService userService;
	
	@Autowired
	protected EventService eventService;
	
	 
	
 
	
	/**
	 * 加载分页列表数据
	 * @param request
	 * @param response
	 * @param session
	 * @param rhs
	 * @return
	 * @throws Exception
	 */
	@Override
	@RequestMapping( method = RequestMethod.POST)
	public String searchPageAjax(HttpServletRequest request,HttpServletResponse response,HttpSession session,Model rhs) throws Exception {
		String className =  getModelClass().getName();
		String uuid=getpara("eventUuid");
		Event event=(Event)EaCommonUtils.getObjectByUuid(uuid, "Event");
		String sql="from " + className + "   where status>"+BaseModel.STATUS_REMOVED +" and event.id="+event.getId() +" and disabled="+EventEnroll.DISABLED_FALSE;
		Map map=request.getParameterMap();
        //按页面提交参数分页查询 
		Pagination p= getPagination( );
		List<EventEnroll> list=null;
		try {
			list = (List<EventEnroll> ) baseService.findByHQLPage(sql, map, "", getParameter("orderBy"),p );
			
			rhs.addAttribute("dataList", list);
			rhs.addAttribute("pagination", p);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error(e.getMessage(),e);
		}
		return rtnDefault(request, response, session, rhs);
	}
	
}
